package com.niiwoo.civet.trade.service.local.fourth;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.niiwoo.civet.trade.dao.entity.RateConfig;
import com.niiwoo.civet.trade.dao.mapper.RateConfigMapperExt;
import com.niiwoo.civet.trade.dto.response.fourth.RateConfigRespDTO;
import com.niiwoo.civet.trade.enums.ProjectTypeEnum;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author jinyouming 2018/9/17
 *
 */
@Service
@Slf4j
public class FourthRateConfigLocalService {
	
	@Autowired
    private RateConfigMapperExt rateConfigMapper;
	
	/**
	 * 查询四周年活动标的费率配置
	 * @param configTypeEnums
	 * @return
	 */
	public List<RateConfigRespDTO> getFourthActivityRateConfig(List<ProjectTypeEnum> configTypeEnums) {
		List<RateConfigRespDTO> respDTO = new ArrayList<RateConfigRespDTO>();
		if(configTypeEnums == null || configTypeEnums.isEmpty()) {
			return respDTO;
		}
		List<RateConfig> rateConfigs = rateConfigMapper.getRateConfigByEnum(configTypeEnums);
		rateConfigs.forEach(rate -> {
			RateConfigRespDTO dto = new RateConfigRespDTO();
			dto.setProductType(rate.getConfigType());
			dto.setProjectTerm(rate.getDeadline());
			dto.setInterestType(rate.getRepaymentMode());
			dto.setInterest(rate.getBorrowInterestRate());
			respDTO.add(dto);
		});
		log.debug("标的费率配置,查询结果值:{}",respDTO);
		return respDTO;
	}

}
